Package kernpruefung.bnz.util
Class CheckMethods
- java.lang.Object
-
- kernpruefung.bnz.util.CheckMethods
-
public class CheckMethods extends Object
The class CheckMethods contains all (static) methods to check the rules from the specifications.
This class is a static class without a public c'tor.
- Version:
- 1.0
- Author:
- Frank Zimmermann (LSV Spitzenverband)
-
-
Field Summary
Fields Modifier and Type Field Description static intBETRIEBSNUMMERstatic intBETRIEBSNUMMER0static intSTICHJAHRstatic intZAHLSTELLENNUMMERstatic intZAHLSTELLENNUMMER0
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanhasCorrectAtChar(String testString)Checks if exactly one @ or § is intestStringand whether it is not in first or last position.static booleanhasForeignLDKZ(String testLDKZ)Checks iftestLDKZis a valid LDKZ (see DEÜV Anlage 8)static booleanhasHomePLZ(String testPLZ)Checks iftestPLZis a valid home PLZ between 01000 ... 99999static booleanhasPLZCharsItl(String testPLZ)Checks iftestPLZhas valid Itl PLZ charsstatic booleanhasValidEmailCharacters(String testString)Checks iftestStringcontains only valid email characters.static booleanisANDefaultValue(String testString)Checks iftestStringhas only the defaultValue (string field: all spaces)static booleanisCheckDigit(String testString, int p)Checks if thetestStringis a valid Zahlstellennummer or Betriebsnummer.
The format of the testString must be 8 digits followed by 7 spaces and hence sums up to a total of 15 characters.static booleanisConstantString(String testString, String constant)Checks if first argument (testString) is equal to the second argument (the constant) and iftestStringis notNULLor empty.static booleanisDate(String testDate)Checks iftestDateis a valid date.static booleanisDate0000(String testDate)Checks iftestDateis a valid date and jhjj<2009 or jhjj<2009 and mmtt="0000".static booleanisDate1LaterDate2(String testDate1, String testDate2)Checks iftestDate1is later thantestDate2.static booleanisDate1NotLaterDate2PlusXMonths(String testDate1, String testDate2, int months)Checks iftestDate1is not later than end of month fromtestDate2plusmonths.static booleanisDateNotLaterToday(String testDate)Checks iftestDateis not later than current date.static booleanisEmptyOrNull(String testString)Checks iftestStringcontains only spaces or isNULLor is an empty string.static booleanisInCharSet(char testChar, String charSet)Checks ifchis member of the charSet given as a stringcharSetstatic booleanisNDefaultValue(String testString)Checks iftestStringhas only the defaultValue (numeric field: all Zeros)static booleanisNumeric(String testString)Checks iftestStringcontains only digits.static booleanisTime(String testTime)Checks iftestTimeis a valid time value.
-
-
-
Field Detail
-
ZAHLSTELLENNUMMER0
public static final int ZAHLSTELLENNUMMER0
- See Also:
- Constant Field Values
-
ZAHLSTELLENNUMMER
public static final int ZAHLSTELLENNUMMER
- See Also:
- Constant Field Values
-
BETRIEBSNUMMER
public static final int BETRIEBSNUMMER
- See Also:
- Constant Field Values
-
BETRIEBSNUMMER0
public static final int BETRIEBSNUMMER0
- See Also:
- Constant Field Values
-
STICHJAHR
public static final int STICHJAHR
- See Also:
- Constant Field Values
-
-
Method Detail
-
isEmptyOrNull
public static boolean isEmptyOrNull(String testString)
Checks iftestStringcontains only spaces or isNULLor is an empty string.CheckMethods.isEmptyOrNull( null ) == true CheckMethods.isEmptyOrNull( "" ) == true CheckMethods.isEmptyOrNull( " " ) == true CheckMethods.isEmptyOrNull( " " ) == true CheckMethods.isEmptyOrNull( " x a " ) == false CheckMethods.isEmptyOrNull( "abc " ) == false
- Parameters:
testString- string that is checked- Returns:
trueif testString contains only spaces or is NULL or is an empty string andfalseotherwise.
-
isNumeric
public static boolean isNumeric(String testString)
Checks iftestStringcontains only digits.CheckMethods.isNumeric( null ) == false CheckMethods.isNumeric( "" ) == false CheckMethods.isNumeric( " " ) == false CheckMethods.isNumeric( "12345" ) == true CheckMethods.isNumeric( "1x2a5" ) == false CheckMethods.isNumeric( "1 234" ) == false
- Parameters:
testString- string that is checked- Returns:
trueiftestStringcontains only digits,falseotherwise.
-
isDate
public static boolean isDate(String testDate)
Checks iftestDateis a valid date.- Parameters:
testDate- string that is checked (format: jhjjmmtt)- Returns:
trueiftestDateis a valid date,falseotherwise.
-
isDate0000
public static boolean isDate0000(String testDate)
Checks iftestDateis a valid date and jhjj<2009 or jhjj<2009 and mmtt="0000".- Parameters:
testDate- string that is checked (format: jhjjmmtt)- Returns:
trueiftestDateis a valid date and jhjj<2009 or jhjj<2009 and mmtt="0000",falseotherwise.
-
isDateNotLaterToday
public static boolean isDateNotLaterToday(String testDate)
Checks iftestDateis not later than current date.- Parameters:
testDate- string that is checked (format: jhjjmmtt)- Returns:
trueiftestDateis not later than current date.
-
isTime
public static boolean isTime(String testTime)
Checks iftestTimeis a valid time value.hh >= 00 and hh <= 23 mm >= 00 and mm <= 59 ss >= 00 and ss <= 59- Parameters:
testTime- string that is checked (format: hhmmss)- Returns:
trueiftestTimeis a valid time value,falseotherwise.
-
hasValidEmailCharacters
public static boolean hasValidEmailCharacters(String testString)
Checks iftestStringcontains only valid email characters.- Parameters:
testString- string that is checked- Returns:
trueiftestStringcontains only valid email characters.
-
hasCorrectAtChar
public static boolean hasCorrectAtChar(String testString)
Checks if exactly one @ or § is intestStringand whether it is not in first or last position.- Parameters:
testString- string that is checked- Returns:
trueif exactly one @ or § is intestStringand is not in first or last position,falseotherwise.
-
isCheckDigit
public static boolean isCheckDigit(String testString, int p)
Checks if thetestStringis a valid Zahlstellennummer or Betriebsnummer.
The format of the testString must be 8 digits followed by 7 spaces and hence sums up to a total of 15 characters.An obligate parameter specifies the check:
param=ZAHLSTELLENNUMMER : Checks if the first 3 positions are resp. 106, 107 or 108 and if the 8. digit is a valid check digit following spec DEÜV 1.3.2.2 . param=BETRIEBSNUMMER : Checks if the first 3 positions are in the range 001 to 099 or greater than 110 and if the 8. digit is a valid check digit following spec DEÜV 1.3.2.2 .The check digit is specified as followed (1.3.2.2 of DEÜV):
- The digits of Betriebsnummer (pos 1 to 7) beginning from left are multiplied with the factors 1,2,1,2,1,2,1..
- From each of this product the sum of the digits is calculated.
- These 7 sums are added.
- The sum is divided by 10.
- The remainder is the check digit.
Example: 87661207 ==> pos : 1 2 3 4 5 6 7 8 (pos 8 = check digit) ======== Digit : 8 7 6 6 1 2 0 7 factor 1-7: 1 2 1 2 1 2 1 +--Calculation--------------------------------------------------------+ ! weighted sum: 8 14 6 12 1 4 0 ! ! sum of digits: 8 5 6 3 1 4 0 ! ! sum: 27 ! ! remainder from division by 10: 7 <--check digit ! !alternative check digit: ! ! check digit + 5: 12 ! ! last digit: 2 <--alternative check digit ! ! ! ! result: valid check digit is : 7 or 2 ! +---------------------------------------------------------------------+- Parameters:
testString- testStringp- specifies the test variant- Returns:
trueiftestStringis a valid Betriebsnummer or Zahlstellennummer
-
isConstantString
public static boolean isConstantString(String testString, String constant)
Checks if first argument (testString) is equal to the second argument (the constant) and iftestStringis notNULLor empty.- Parameters:
testString- test string that is compared with constantconstant- the constant for that the check is performed- Returns:
trueiftestStringis equal to the constant, otherwisefalse
-
isInCharSet
public static boolean isInCharSet(char testChar, String charSet)Checks ifchis member of the charSet given as a stringcharSet- Parameters:
testChar- character to be checkedcharSet- character set to be checked against- Returns:
trueifcharSetcontains thetestChar,falseotherwise
-
isDate1LaterDate2
public static boolean isDate1LaterDate2(String testDate1, String testDate2)
Checks iftestDate1is later thantestDate2. IftestDate1ortestDate2is NULL it is replaced with current Date- Parameters:
testDate1- (Format: jhjjmmtt)testDate2- (Format: jhjjmmtt)- Returns:
trueiftestDate1is later thantestDate2, otherwisefalse
-
isDate1NotLaterDate2PlusXMonths
public static boolean isDate1NotLaterDate2PlusXMonths(String testDate1, String testDate2, int months)
Checks iftestDate1is not later than end of month fromtestDate2plusmonths. IftestDate1ortestDate2is NULL it is replaced with current Date- Parameters:
testDate1- (Format: jhjjmmtt)testDate2- (Format: jhjjmmtt)months- number of months to add to testDate2 before comparing to testDate1- Returns:
trueiftestDate1is not later than end of month fromtestDate2plusmonths, otherwisefalse
-
isNDefaultValue
public static boolean isNDefaultValue(String testString)
Checks iftestStringhas only the defaultValue (numeric field: all Zeros)- Parameters:
testString- numeric string to be checked- Returns:
trueiftestStringhas only the defaultValue (numeric field:all Zeros), otherwisefalse
-
isANDefaultValue
public static boolean isANDefaultValue(String testString)
Checks iftestStringhas only the defaultValue (string field: all spaces)- Parameters:
testString- alphanumeric string to be checked- Returns:
trueiftestStringhas only the defaultValue (string field: all spaces), otherwisefalse
-
hasForeignLDKZ
public static boolean hasForeignLDKZ(String testLDKZ)
Checks iftestLDKZis a valid LDKZ (see DEÜV Anlage 8)CheckMethods.hasForeignLDKZ( "" ) == false CheckMethods.hasForeignLDKZ( " " ) == false CheckMethods.hasForeignLDKZ( "BHT" ) == true CheckMethods.hasForeignLDKZ( "IRL" ) == true CheckMethods.hasForeignLDKZ( "xxx" ) == false CheckMethods.hasForeignLDKZ( " L " ) == false
- Parameters:
testLDKZ- LDKZ that is to be tested (LDKZ is short for: Länderkennzeichen)- Returns:
trueiftestLDKZis a valid LDKZ,falseotherwise
-
hasHomePLZ
public static boolean hasHomePLZ(String testPLZ)
Checks iftestPLZis a valid home PLZ between 01000 ... 99999CheckMethods.hasHomePLZ( "" ) == false CheckMethods.hasHomePLZ( " " ) == false CheckMethods.hasHomePLZ( "01000 " ) == true CheckMethods.hasHomePLZ( "44866 " ) == true CheckMethods.hasHomePLZ( "00010 " ) == false CheckMethods.hasHomePLZ( " 44866 " ) == false
- Parameters:
testPLZ- postalcode that is to be tested (PLZ is short for: Postleitzahl/postalcode)- Returns:
trueiftestPLZis a valid home PLZ,falseotherwise
-
hasPLZCharsItl
public static boolean hasPLZCharsItl(String testPLZ)
Checks iftestPLZhas valid Itl PLZ chars- Parameters:
testPLZ- postalcode that is to be tested (PLZ is short for: Postleitzahl/postalcode)- Returns:
trueiftestPLZhas valid Itl PLZ chars,falseotherwise
-
-